From c688fa3851263dc29075182ffdb1ab83051a7213 Mon Sep 17 00:00:00 2001
From: Chris Taylor <chris@code-monkeys.org>
Date: Fri, 05 Mar 2010 06:13:15 +0000
Subject: Fix segfault and possible overflow.

-Fix segfault when opening directory, and the buffer length is 0.
-Fix possible overflow in buffer.

Signed-off-by: Chris Taylor <chris@code-monkeys.org>
---
diff --git a/browse.c b/browse.c
index fd06dee..c736e64 100644
--- a/browse.c
+++ b/browse.c
@@ -399,16 +399,19 @@ void open_directory( void )
                                         get_contents();
                                         return;
 				case ENTER:
+                                    if(strlen(buffer)==0) return;
+                                    else {
                                         cont.location=g_strdup(buffer);
                                         g_chdir(buffer);
                                         get_contents();
+                                    }
                                         return;
 				case KEY_BACKSPACE:
 					if (len == 0) break;
 					buffer[--len] = '\0';
 					break;
 				default:
-					if (len == 1025) break;
+					if (len >= 1024) break;
 					if (c < 32) break;
 					buffer[len] = c;
 					buffer[++len] = '\0';
--
cgit v0.8.3.4-115-g1759
